package com.example.demo.sys.service.impl;

import com.example.demo.core.utils.BeanConvertor;
import com.example.demo.sys.dao.RoleRepository;
import com.example.demo.sys.entity.Role;
import com.example.demo.sys.service.RoleService;
import com.example.demo.sys.service.bo.RoleBO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoleServiceImpl implements RoleService {
    @Autowired
    private RoleRepository roleRepository;

    @Override
    public void addRole(RoleBO roleBO) {
        roleRepository.save(BeanConvertor.transfer(roleBO, Role::new));
    }

    @Override
    public void updateRole(RoleBO roleBO) {
        roleRepository.save(BeanConvertor.transfer(roleBO, Role::new));
    }

    @Override
    public void removeRolesByIds(List<Integer> ids) {
        roleRepository.deleteAllById(ids);
    }
}
